package com.muyu.danmo.service.impl;

import com.muyu.common.core.utils.DateUtils;
import com.muyu.danmo.domain.DanmoAnnouncement;
import com.muyu.danmo.mapper.DanmoAnnouncementMapper;
import com.muyu.danmo.service.IDanmoAnnouncementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 广告Service业务层处理
 *
 * @author yangle
 * @date 2024-09-19
 */
@Service
public class DanmoAnnouncementServiceImpl implements IDanmoAnnouncementService
{
    @Autowired
    private DanmoAnnouncementMapper danmoAnnouncementMapper;

    /**
     * 查询广告
     *
     * @param id 广告主键
     * @return 广告
     */
    @Override
    public DanmoAnnouncement selectDanmoAnnouncementById(Long id)
    {
        return danmoAnnouncementMapper.selectDanmoAnnouncementById(id);
    }

    /**
     * 查询广告列表
     *
     * @param danmoAnnouncement 广告
     * @return 广告
     */
    @Override
    public List<DanmoAnnouncement> selectDanmoAnnouncementList(DanmoAnnouncement danmoAnnouncement)
    {
        return danmoAnnouncementMapper.selectDanmoAnnouncementList(danmoAnnouncement);
    }

    /**
     * 新增广告
     *
     * @param danmoAnnouncement 广告
     * @return 结果
     */
    @Override
    public int insertDanmoAnnouncement(DanmoAnnouncement danmoAnnouncement)
    {
        danmoAnnouncement.setCreateTime(DateUtils.getNowDate());
        return danmoAnnouncementMapper.insertDanmoAnnouncement(danmoAnnouncement);
    }

    /**
     * 修改广告
     *
     * @param danmoAnnouncement 广告
     * @return 结果
     */
    @Override
    public int updateDanmoAnnouncement(DanmoAnnouncement danmoAnnouncement)
    {
        danmoAnnouncement.setUpdateTime(DateUtils.getNowDate());
        return danmoAnnouncementMapper.updateDanmoAnnouncement(danmoAnnouncement);
    }

    /**
     * 批量删除广告
     *
     * @param ids 需要删除的广告主键
     * @return 结果
     */
    @Override
    public int deleteDanmoAnnouncementByIds(Long[] ids)
    {
        return danmoAnnouncementMapper.deleteDanmoAnnouncementByIds(ids);
    }

    /**
     * 删除广告信息
     *
     * @param id 广告主键
     * @return 结果
     */
    @Override
    public int deleteDanmoAnnouncementById(Long id)
    {
        return danmoAnnouncementMapper.deleteDanmoAnnouncementById(id);
    }
}
